﻿
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[sproc_Flow_GetReceiver]') AND type in (N'P', N'PC'))
    DROP PROCEDURE [dbo].[sproc_Flow_GetReceiver];
GO
CREATE PROCEDURE [dbo].[sproc_Flow_GetReceiver]
    @DocID int
AS
SELECT     A.*,
    DATEDIFF(yy,a.birthday,getdate()) as Age,
    (CASE sex WHEN 1 then '男' else '女' end) as SexName,
    Convert(nvarchar(10),A.RegistedDate,120) AS RQ,
    (SELECT Position_name FROM uds_Position WHERE Position_id = b.Position_id) AS Position_Name
    FROM 
        uds_staff A,
        uds_staff_in_position b
    WHERE     a.staff_id = b.staff_id
        and a.staff_id IN
            (    
                SELECT staff_id 
                    FROM uds_flow_status
                    WHERE doc_id = @DocID
            )